#pragma once

#include "Component.h"
#include "D3DApp.h"


class SpriteText :
	public Component
{
public:
	SpriteText();
	SpriteText(const std::string& police, const std::string& message);
	SpriteText(const std::string& police, const std::string& message, float x, float y);
	SpriteText(const std::string& police, const std::string& message, D3DXVECTOR3* position);
	SpriteText(const std::string& police, const std::string& message, int width, int height);
	SpriteText(const std::string& police, const std::string& message, int width, int height, float x, float y);
	SpriteText(const std::string& police, const std::string& message, int width, int height, D3DXVECTOR3* position);
	SpriteText(const std::string& police, const std::string& message, int width, int height, D3DCOLOR color);
	SpriteText(const std::string& police, const std::string& message, int width, int height, D3DCOLOR color, float x, float y);
	SpriteText(const std::string& police, const std::string& message, int width, int height, D3DCOLOR color, D3DXVECTOR3* position);

	void CreateMyFont();

	RECT GetTextRect();
	void CenterRect(RECT* toCenter);
	void MoveToPosition(RECT* toPlace);

	void OnLostDevice();
	void OnResetDevice();
	void Update(float dt);
	void Draw(ID3DXSprite* sprite, D3DXMATRIX& view, D3DXMATRIX& proj);
	
	std::string GetText()
	{
		return mMessage;
	}

	void SetFont(const std::string& path)
	{ 
		this->mPolice = path;
		CreateMyFont();
	}

	void SetSize(int width, int height)
	{
		this->width = width;
		this->height = height;
		CreateMyFont();
	}

	void SetStyle(bool isItalic)
	{
		this->isItalic = isItalic;
		CreateMyFont();
	}

	void SetMessage(const std::string& message)
	{
		this->mMessage = message;
	}

	void SetColor(D3DCOLOR color)
	{
		this->mColor = color;
	}

	void SetPosition(float x, float y)
	{
		this->x = x;
		this->y = y;
	}

	void SetPosition(D3DXVECTOR3* position)
	{
		this->x = position->x;
		this->y = position->y;
	}

	virtual ~SpriteText();
private:
	float x;
	float y;
	int width;
	int height;
	bool isItalic;
	ID3DXFont* mFont;

	D3DCOLOR mColor;

	std::string mPolice;
	std::string mMessage;
};





